package org.test.client.ui.skinui.checkbox;

import java.awt.Image;

import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;

public class PicFactory {
	private static String checkboxNormal = "res/cb_normal.png";
	private static String checkboxDisable = "res/cb_disable.png";
	private static String checkboxPressed = "res/cb_pressed.png";
	private static String checkboxNormal1 = "res/cb_un_normal.png";
	private static String checkboxDisable1 = "res/cb_un_disable.png";
	private static String checkboxPressed1 = "res/cb_un_pressed.png";
	
	private static String radioNormal = "res/rb_normal.png";
	private static String radioDisable = "res/rb_disable.png";
	private static String radioPressed = "res/rb_pressed.png";
	private static String radioNormal1 = "res/rb_un_normal.png";
	private static String radioDisable1 = "res/rb_un_disable.png";
	private static String radioPressed1 = "res/rb_un_pressed.png";

	static String[] CBPICPath = new String[] { checkboxNormal, checkboxNormal1,
		checkboxDisable, checkboxDisable1, checkboxPressed,checkboxPressed1 };
	
	static String[] RBPICPath = new String[] { radioNormal, radioNormal1,
			radioDisable, radioDisable1, radioPressed, radioPressed1 };
	
	private static Image[] cbIcons = new Image[6];
	private static Image[] rbIcons = new Image[6];
	
	public static final int CB_NORMAL = 0;
	public static final int CB_UN_NORMAL = 1;
	public static final int CB_DISABLE = 2;
	public static final int CB_UN_DISABLE = 3;
	public static final int CB_PRESSED = 4;
	public static final int CB_UN_PRESSED = 5;
	
	public static final int RB_NORMAL = 0;
	public static final int RB_UN_NORMAL = 1;
	public static final int RB_DISABLE = 2;
	public static final int RB_UN_DISABLE = 3;
	public static final int RB_PRESSED = 4;
	public static final int RB_UN_PRESSED = 5;
	
	static{
		try {
			for(int i=0;i<cbIcons.length;i++){
				cbIcons[i] = loadIcon(CBPICPath[i]);
			}
			
			for(int i=0;i<rbIcons.length;i++){
				rbIcons[i] = loadIcon(RBPICPath[i]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private static Image loadIcon(String str) throws Exception{
		return ImageIO.read(PicFactory.class.getResourceAsStream(str));
	}
	
	public static Image getCheckBoxIcon(int type){
		return cbIcons[type];
	}
	
	public static Image getRadioIcon(int type){
		return rbIcons[type];
	}
}
